class MsuiDataGridItemModel {
  constructor({
    width,
    prop,
    label,
    align = 'center',
    show = true,
    showTip = true
  } = {}) {
    this.width = width
    this.prop = prop
    this.label = label
    this.align = align
    this.show = show
    this.sortable = false
    this.showOverflowTooltip = showTip
  }
  set(obj) {
    for (let key in obj) {
      this[key] = obj[key]
    }
    return this
  }
  /**
   * 表格排序
   * @param {*} custom
   * @returns
   */
  formatter(formatters) {
    this.formatters = (value) => {
      if (this.data instanceof Promise) {
        this.data.then(() => {
          this.formatters = formatters
        })
        return value
      } else {
        this.formatters = formatters
      }
    }
    return this
  }
  formatterData({ data }) {
    this.data = data
    if (data instanceof Promise) {
      data.then((data) => {
        this.data = data
      })
    }
    return this
  }
}

export default MsuiDataGridItemModel
